package com.mavenq.fly.test;

import org.junit.Test;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class testPatten {

    /**
     * 时间格式
     */
    @Test
    public void testTimePatten(){
        String str = "24:00";
        String pattern = "^(([0-1]\\d)|(2[0-3])):[0-5]\\d$";

        Pattern r = Pattern.compile(pattern);
        Matcher m = r.matcher(str);
        System.out.println(m.matches());
    }

    @Test
    public void testTimeCompare(){
        boolean matchTimeRule = Times.isMatchTimeRule("12:30");
        System.out.println(matchTimeRule);
        int i = Times.timeToMill("23:30");
        int i2 = Times.timeToMill("00:00");
        System.out.println(i>i2);
    }

    @Test
    public void getCurrentTime(){
        LocalDate date = LocalDate.now(); // get the current date
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
        System.out.println(date.format(formatter));
        System.out.println(Integer.parseInt(LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"))) -1);
    }
}
